首页

欢迎

 

Welcome

欢迎来到这里, 这是一个学习数学、讨论数学的网站.

转到问题

请输入问题号, 例如: 2512

IMAGINE, THINK, and DO
How to be a scientist, mathematician and an engineer, all in one?
--- S. Muthu Muthukrishnan

Local Notes

Local Notes 是一款 Windows 下的笔记系统.

Local Notes 下载

Sowya

Sowya 是一款运行于 Windows 下的计算软件.

详情

下载 Sowya.7z (包含最新版的 Sowya.exe and SowyaApp.exe)


注: 自 v0.550 开始, Calculator 更名为 Sowya. [Sowya] 是吴语中数学的发音, 可在 cn.bing.com/translator 中输入 Sowya, 听其英语发音或法语发音.





注册

欢迎注册, 您的参与将会促进数学交流. 注册

在注册之前, 或许您想先试用一下. 测试帐号: usertest 密码: usertest. 请不要更改密码.


我制作的 slides

Problem

随机显示问题

Problèmes d'affichage aléatoires

软件 >> Calculator >> 开发计划
Questions in category: 开发计划 (DevPlan).

[DevPlan] 给定数列的递推公式, 打印数列的前若干项.

Posted by haifeng on 2023-02-04 10:15:46 last update 2023-02-05 20:57:46 | Answers (0)


设 $a_{n+1}=\dfrac{a_n^2+2}{a_n+4}$, $a_1=2$, 求出数列 $\{a_n\}$ 的前若干项.

 

注: 此题来源 https://bbs.emath.ac.cn/thread-18747-1-1.html


目前可以这样做, 令 $y=\dfrac{x^2+2}{x+4}$, 初始值 $x=2$. 求出 $y$ 后替代 $x$, 然后再计算 $y$.

 

>> x=2
--------------------
>> y=(x^2+2)/(x+4)
----------------------------
 type: string
 name: y
value: (x^2+2)/(x+4)
value_computed: 1
--------------------
>> x=y
----------------------------
 type: string
 name: x
value: (y)
value_computed: 1
--------------------
>> y=(x^2+2)/(x+4)
----------------------------
 type: string
 name: y
value: (x^2+2)/(x+4)
value_computed: 0.6
--------------------
>> y
in> (0.6)

out> 0.6

------------------------


即得到

\[
a_1=2,\quad a_2=1,\quad a_3=\frac{3}{5},\quad a_4=\frac{59}{115}
\]


在 Calculator v0.537 版本中已经添加了函数 printRecursiveSeries()

>> printRecursiveSeries((n^2+2)/(n+4),n,2,10,\n)
in> printRecursiveSeries((n^2+2)/(n+4),n,2,10,\n)
1
0.6
0.51304348
0.50148278
0.50016519
0.50001836
0.50000204
0.50000023
0.50000003
0.50000000


------------------------

>> :mode=fraction
Switch into fraction calculating mode.
e.g., 1/2+1/3 will return 5/6

>> printRecursiveSeries((n^2+2)/(n+4),n,2,10,\n)
in> printRecursiveSeries((n^2+2)/(n+4),n,2,10,\n)
1
3|5
59|115
9977|19895
891162579|1781736515
7143340759978621691|14286156943343253085
153071959210947077593344209777606577977|306142669345391339033273867001310578545
210877692684521073632686796614427621177608849307584544993392729791345410046579|421755194170454656838715623548179223078639124055129803382668276046037982971565
400224288891463132245588513262675832580155294150347514542265716671466587416216808432328845025373819376120940561495311696075422019773351889910473522146701691|800448537463409289970468912605629751484284184673346880817551678682345444242416699895610264410961644842938069217110623535798264962551964970919962105876723035
480538401224433076914322107044892889273619273662533194150556851587360737976789610786946600683365362655087382494630247466268531496887249965680481862880481156186674147551392766374398353649598099830434467531101824929956726062281597466600813520823786097638583908474247882847900409669162905195171606419138016780493977|961076797069916150637035067794869620082760044754356287427841416504669963950089965195105960796484833842639813529070119301247099221843344998442808673021667792117820296445588510208551637135412798708771976135899044690996631347449387596569472159842757832149769436510643469544737024421672111730371918134099365723865695


------------------------


需要能处理复杂的递推关系, 比如

\[
\begin{cases}
a_n&=2a_{n-1}+2a_{n-2},\\
a_1&=3,\\
a_2&=8.
\end{cases}
\]